<div class="fltlist-list-wrapper">
    <div class="fltlist-list-cache-item"><!----></div>
    <div class="fltlist-list-item">
        <#--<div class="fltlist-list-roundway-line" style="display: none;">
            <button>收起<i class="fltlist-airline-up"></i></button>
        </div>-->

        <#list pageInfo.list as a>
            <div class="v-list-item-content">
                <div class="v-list-item-icon"><i class="fltlist-logo fltlist-logo-${(a.flight!)[0..1]}"></i><span
                            class="v-list-item-tag"></span></div>
                <div class="v-list-item-name">
                    <div class="v-list-item-desc">${a.airlines.name!}<span>${a.flight!}</span></div>
                    <div class="v-list-item-info"><span>${a.airplaneType!}</span><!----></div>
                </div>
                <div class="v-list-item-time">
                    <div class="v-list-item-time-time">${(a.beginFlyTime?string('HH:mm'))!}</div>
                    <div class="v-list-item-info">${a.beginAirport.name}${a.beginHZL}</div>
                </div>
                <div class="v-list-item-line">
                    <div class="line-wrapper">
                        <div class="line-time">${a.betweenTime!}</div>
                        <div class="line"></div><!---->
                    </div>
                </div>
                <div class="v-list-item-time v-list-item-time-to">
                    <div class="v-list-item-time-time">${(a.endFlyTime?string('HH:mm'))!}</div>
                    <div class="v-list-item-info">${a.endAirport.name!}${a.endHZL!}</div><!----></div>
                <div class="v-list-item-price">
                    <div class="v-list-item-price-desc">
                        <div><span>￥</span>${a.price!}<span class="gray">起</span></div><!----></div>
                </div>
                <div class="v-list-item-ticket">
                    <#--<button class="v-list-item-button"  data-json="${a.id}">订票</button>-->

                    <#if qo.type == 1>
                        <button class="v-list-item-button"  data-json="${a.id}">订票</button>
                    <#else>
                        <button class="v-list-item-button"  data-way="go" data-json="${a.id}">选为去程</button>
                       <#-- <button class="v-list-item-button" style="display: none" data-json="${a.id}">订票</button>-->
                    </#if>

                </div>
                <div class="v-list-item-ticket" style="display: none;">
                    <button class="v-list-item-fold">收起<i class="fltlist-airline-up"></i></button>
                </div>
            </div>
        </#list>
    </div><!----><!----><!----></div>
<div style="float: right">
    <div style="float: left;" ><span style="line-height:30px"> 共${pageInfo.pages}页 / ${pageInfo.total}条&nbsp;&nbsp;&nbsp;</span></div>
    <div id="pagination" class="jq-pagination" style="display: inline;"></div>
</div>


<script>

    var panduan;
    var temp;
    $(function () {

        //抽出来的多条件查询
        function queryLine(page) {

            orgCity = $("#departCity").val();
            dstCity = $("#destCity").val();
            var deptTime = $("#depTime").val();
            var sourTime = $("#sourTime").val();
            var type = $("#_way_btn").attr("data-val");

            var flytime = $("input.flytime").attr("data-val");
            var flysour = $("input.flysour ").attr("data-val");
            var flydest = $("input.flydest ").attr("data-val");
            var flycop = $("input.flycop ").attr("data-val");
            var flysize = $("input.flysize").attr("data-val");

            var orderby = $(".fltlist-airline-col").children("span").children(".active").attr("data-val");
            console.log(orderby);

            if (!orgCity) {
                alert("出发地不能为空");
                return;
            } else if (!dstCity) {
                alert("目的地不能为空");
                return;
            } else if (!deptTime) {
                alert("出发时间不能为空");
            } else {

                if (!panduan){

                    $.post("/flight/find", {
                        orgCity: orgCity, dstCity: dstCity, depTime: deptTime,
                        type: type,
                        flytimeType: flytime, beginAirportId: flysour, endAirportId: flydest,
                        airlinesId: flycop, size: flysize, orderby: orderby,currentPage: page ? currentPage : 1
                    }, function (data) {
                        $("#contentList").empty();
                        $("#contentList").append(data);


                    });
                } else{

                    $.post("/flight/find", {
                        orgCity: dstCity, dstCity: orgCity, depTime: sourTime,
                        type: type,
                        flytimeType: flytime, beginAirportId: flysour, endAirportId: flydest,
                        airlinesId: flycop, size: flysize, orderby: orderby,currentPage: page ? currentPage : 1
                    }, function (data) {
                        $("#contentList").empty();
                        $("#contentList").append(data);
                        $("button.v-list-item-button").text("订票");
                        $("button.v-list-item-button").removeAttr("data-way");

                    });
                }



            }
        }

        //查返程
        function queryBack() {

            orgCity = $("#departCity").val();
            dstCity = $("#destCity").val();
            var deptTime = $("#depTime").val();
            var sourTime = $("#sourTime").val();
            type = $("#_way_btn").attr("data-val");

            $(".fltlist-airline-col").children("span").children("i").removeClass("active");
            $("#price").children(".fltlist-airline-up").addClass("active");
            var orderby = $(".fltlist-airline-col").children("span").children(".active").attr("data-val");

            if (!orgCity) {
                alert("出发地不能为空");
                return;
            } else if (!dstCity) {
                alert("目的地不能为空");
                return;
            } else if (!deptTime) {
                alert("出发时间不能为空");
            } else {
                $.post("/flight/find", {
                    orgCity: dstCity, dstCity: orgCity, depTime: sourTime,
                    type: type, orderby: orderby,currentPage:1
                }, function (data) {

                    $("#contentList").empty();
                    $("#contentList").append(data);
                    $("button.v-list-item-button").text("订票");
                    $("button.v-list-item-button").removeAttr("data-way");

                });
            }
        }

        //去程信息
        //去程信息



        $(".v-list-item-button").click(function(){

            if ($(this).attr("data-way")){
                var json = $(this).attr("data-json");
                temp = json;
                $.post("/flight/getGoTripInfo",{id:json},function(data){
                    if (data){
                        queryBack();
                        $(".flight_info").remove();
                        $("#backHint").removeAttr("style");
                        $(".fltlist-selected-plane").after(data);
                        panduan = 1;
                    }
                });

            }else{

                if (panduan == 1) {
                    $("input[name=depId]").val(temp);
                    $("input[name=bacId]").val($(this).attr("data-json"));
                    $("#orders").submit();
                }else{
                    $("input[name=depId]").val($(this).attr("data-json"));
                    $("input[name=bacId]").val(-1);
                    $("#orders").submit();

                }

            }

        });

        //分页
        $("#pagination").jqPaginator({
            totalPages: ${pageInfo.pages}||1,
            visiblePages: 1,
            currentPage: ${pageInfo.pageNum}||1,
            prev: '<a class="prev" href="javascript:void(0);">上一页<\/a>',
            next: '<a class="next" href="javascript:void(0);">下一页<\/a>',
            page: '<a href="javascript:void(0);">{{page}}<\/a>',
            last: '<a class="last" href="javascript:void(0);" >尾页<\/a>',
            onPageChange: function(page, tp) {
            if(tp == 'change'){
                currentPage = page;
                queryLine(page);
            }

        }
    })

    });




</script>